01. Pre-Notebook: Custom Models & Moon Data

Notebook: Custom Models & Moon Data, Exercise

Next, you'll approach the task of building and training a custom PyTorch classifier to classify data! Specifically, you'll be tasked with classifying "moon data," which is 2-dimensional data whose classes are distributed to look a bit like moons in 2D space.

Slightly noisy, purple (top) and yellow (bottom) "moon" data.

Slightly noisy, purple (top) and yellow (bottom) "moon" data.

Building and training a custom model is presented as an alternative to something like a LinearLearner, which is great in many cases but may fail for data that is not easily separable. As you follow along with this lesson, you should work in the referenced SageMaker notebooks. We will present a solution to you, but please try to work on a solution of your own, when prompted. Much of the value in this experience will come from experimenting with the code, in your own way .

To open this notebook:

  • Navigate to your SageMaker notebook instance, in the SageMaker console , which has been linked to the main Github exercise repository
  • Activate the notebook instance (if it is in a "Stopped" state), and open it via Jupyter
  • Click on the exercise notebook in the Moon_Data directory.

You may also directly view the exercise and solution notebooks via the repository at the following links:

In this particular case, you will also find a directory source and source_solution for further reference.

The solutions are meant to be consulted if you are stuck or want to check your work.

Notebook Outline

We'll go over the following steps to complete the notebook.

  • Upload data to S3
  • Define a PyTorch neural network for binary classification
  • Write a custom training script
  • Train and evaluate the custom model

Later: Delete Resources

At the end of this exercise, and intermittently, you will be reminded to delete your endpoints and resources so that you do not incur any extra processing or storage fees!